package com.hxl.demo.controller;

import com.hxl.demo.entity.Dept;
import com.hxl.demo.service.DeptService;
import com.hxl.demo.tools.Common;
import com.hxl.demo.tools.PageInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class DeptController {
    @Resource
    private DeptService deptService;

    /**
     * 查询所有部门信息
     * @return
     */
    @RequestMapping("/getDeptAll")
    public Object getDeptAll(Dept dept,
                             @RequestParam(value = "begin") String begin,
                             @RequestParam(value = "limit") String limit) {
        int start = begin == null ? 0 : Integer.parseInt(begin);
        int length = limit == null ? 15 : Integer.parseInt(limit);

        PageInfo<Dept> page = deptService.page(start, length, dept);
        return Common.returnJsonSuccess("成功",200,page);
    }
}
